package com.ruoyi.performance.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.performance.domain.PerfTarget;
import com.ruoyi.performance.dto.PerfTargetDto;
import com.ruoyi.performance.service.PerfTargetService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 考核细项指标 提供者
 * 
 * @author YL
 * @date 2020-07-22
 * @description
 */
@RestController
@RequestMapping("perftarget")
public class PerfTargetController extends BaseController {
	
	@Resource
	private PerfTargetService perfTargetService;
	
	/**
	 * 根据ID查询
	 */
	@GetMapping("get/{id}")
	public R get(@PathVariable("id") int id) {
		return jacResult(perfTargetService.selectPerfTargetById(id));
		
	}
	
	/**
	 * 查询考核细项指标列表
	 */
	@GetMapping("list")
	public R list(PerfTargetDto perfTargetDto) {
		startPage();
        return result(perfTargetService.selectPerfTargetList(perfTargetDto));
	}
	
	
	/**
	 * 新增保存考核细项指标
	 */
	@PostMapping("save")
	public R addSave(@RequestBody PerfTarget perfTarget) {
		return toAjax(perfTargetService.insertPerfTarget(perfTarget));
	}

	/**
	 * 修改保存考核细项指标
	 */
	@PostMapping("update")
	public R editSave(@RequestBody PerfTarget perfTarget) {
		return toAjax(perfTargetService.updatePerfTarget(perfTarget));
	}
	
	/**
	 * 删除
	 */
	@PostMapping("remove")
	public R remove(int id) {
		return toAjax(perfTargetService.deletePerfTargetById(id));
	}
	
}
